Python is a widely used high-level programming language for general-purpose programming, created by Guido Van Rossum and first released in 1991. An interpreted language, Python has a design philosophy which emphasizes code readability (notably using whitespace indentation to delimit code blocks rather than curly brackets or keywords), and a syntax which allows programmers to express concepts in fewer lines of code than might be used in languages such as C++ or Java. The language provides constructs intended to enable writing clear programs on both a small and large scale.
We assume that you have:
C LanguageC++,Java or C#These Software must be installed to follow the Language tutorial.
apt install it )apt install it)We will be using several libraries throughout the tutorial. They can be installed with pip (or pip3) as
pip install <library-name>. Following is a list of libraries that has to be installed to follow the tutorial.
matplotlib (For visualizing data sets)numpy (For faster array operations)networkx (Provides Graph Data Structure) - OpenAnalysis (An open source package to analyse and visualise algorithms and data structures)As a tradition, we start with a program to display Hello World on the Console Screen (the stdout)
Open the Interative Python Shell by typing ipython(or ipython3) from the terminal.
If everything goes well, you will get a prompt where you can enter statements and see the effect of it. Now enter the following statement to get started
In [1]:
print("Hello World")
Congrats! You have successfully executed your first statement in Python. In fact there are many ways to execute python statements. Interactive Console is one of them. You can also pack the statements into single file, whose name ends with an extension .py, and call python (or python3) to execute them. We will also check this method to execute Python statements. Save the contents of below cell into a file named first.py.
Run this command to execute the file
python3 first.py # Or python
In [1]:
print("Hello World")
print("Hi from Python File")
Example:
In [2]:
print('a','b','c',sep=':',end=',')
print('e','f','g',sep='.')